package com.ruoyi.web.controller.fitnesspowers;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fitnesspowers.domain.FitImageresources;
import com.ruoyi.fitnesspowers.service.IFitImageresourcesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 首页图片Controller
 * 
 * @author lzb
 * @date 2023-06-13
 */
@Api("首页图片Controller")
@RestController
@RequestMapping("/fitnesspowers/imageresources")
public class FitImageresourcesController extends BaseController
{
    @Autowired
    private IFitImageresourcesService fitImageresourcesService;

    /**
     * 查询首页图片列表
     */
    @PreAuthorize("@ss.hasPermi('fitnesspowers:imageresources:list')")
    @GetMapping("/list")
    @ApiOperation("查询首页图片列表")
    public TableDataInfo list(FitImageresources fitImageresources)
    {
        startPage();
        List<FitImageresources> list = fitImageresourcesService.selectFitImageresourcesList(fitImageresources);
        return getDataTable(list);
    }

    /**
     * 导出首页图片列表
     */
    @PreAuthorize("@ss.hasPermi('fitnesspowers:imageresources:export')")
    @Log(title = "首页图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FitImageresources fitImageresources)
    {
        List<FitImageresources> list = fitImageresourcesService.selectFitImageresourcesList(fitImageresources);
        ExcelUtil<FitImageresources> util = new ExcelUtil<FitImageresources>(FitImageresources.class);
        util.exportExcel(response, list, "首页图片数据");
    }

    /**
     * 获取首页图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('fitnesspowers:imageresources:query')")
    @GetMapping(value = "/{fitId}")
    public AjaxResult getInfo(@PathVariable("fitId") Long fitId)
    {
        return success(fitImageresourcesService.selectFitImageresourcesByFitId(fitId));
    }

    /**
     * 新增首页图片
     */
    @PreAuthorize("@ss.hasPermi('fitnesspowers:imageresources:add')")
    @Log(title = "首页图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FitImageresources fitImageresources)
    {
        return toAjax(fitImageresourcesService.insertFitImageresources(fitImageresources));
    }

    /**
     * 修改首页图片
     */
    @PreAuthorize("@ss.hasPermi('fitnesspowers:imageresources:edit')")
    @Log(title = "首页图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FitImageresources fitImageresources)
    {
        return toAjax(fitImageresourcesService.updateFitImageresources(fitImageresources));
    }

    /**
     * 删除首页图片
     */
    @PreAuthorize("@ss.hasPermi('fitnesspowers:imageresources:remove')")
    @Log(title = "首页图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fitIds}")
    public AjaxResult remove(@PathVariable Long[] fitIds)
    {
        return toAjax(fitImageresourcesService.deleteFitImageresourcesByFitIds(fitIds));
    }
}
